package com.neal.conf;

import com.neal.common.ResourcesUtils;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.io.IOException;

/**
 * @author Neal
 * @createdDate 2014-5-26
 */
@Configuration
@ComponentScan(basePackageClasses = {AppConfig.class})
@EnableScheduling
@EnableCaching
public class AppConfig {

    public static String SITE_DEFAULT_ENCODING = "UTF-8";
    
    @Bean
    public PropertyPlaceholderConfigurer getPropertyPlaceholderConfigurer() throws IOException {
        PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
        configurer.setLocations(ResourcesUtils.getResources("classpath*:/config/*.properties"));
        return configurer;
    }

    @Bean
    public CacheManager cacheManager() {
        return new ConcurrentMapCacheManager();
    }
}
